# -*- coding: utf-8 -*-
from ..base.Validator import Validator
import re
"""
 * ip验证器
 *<B>说明：</B>
 *<pre>
 * 规则格式:
 * ['attrs',[['ip']],{'message'=>'你的输入ip 格式有误！'}]
 *</pre>
 *<B>示例：</B>
 *<pre>
 *  略
 *</pre>
 *<B>日志：</B>
 *<pre>
 *  略
 *</pre>
 *<B>注意事项：</B>
 *<pre>
 *  略
 *</pre>
"""
class IpValidator(Validator):

    def __init__(self,attrs,validation = None):
        self.pattern = r'^(\d+\.\d+\.\d+\.\d+)$'
        super().__init__(attrs,validation)


    def validateValue(self,value,name = None):

        if re.match(self.pattern, value) is not None:
            return True
        else:
            return False